<template>
  <div id="app">
  	<audio src="/static/media/bgm.mp3" loop="true" ref="bgm"></audio>
  	<div class="bgm on" @click="onToggle" ref="bgmicon"></div>
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: 'app',
  mounted() {
  	document.addEventListener('WeixinJSBridgeReady', () => {
  		document.addEventListener('DOMContentLoaded', () => {
  			this.$refs.bgm.play();
  		}, false);
		this.$refs.bgm.play();
  	}, false);
  },
  methods: {
  	onToggle() {
  		if (this.$refs.bgm.paused) {
  			this.$refs.bgmicon.classList.remove('off');
  			this.$refs.bgm.play();
  		} else {
  			this.$refs.bgmicon.classList.add('off');
  			this.$refs.bgm.pause();
  		}
  	}
  }
}
</script>

<style lang="less">
@import '~vux/src/styles/reset.less';

html, body, #app-box {
	width: 100%;
	height: 100%;
	margin: 0 auto;
	background: #666;
	-webkit-tap-highlight-color: rgba(0,0,0,0);
}

#app {
	width: 100%;
	height: 100%;
	position: relative;
	background: white;
}


@keyframes rotate {
	to {
		transform: rotate(360deg);
	}
}
.bgm {
	position: absolute;
	width: 30px;
	height: 30px;
	right: 20px;
	top: 20px;
	z-index: 10;
	animation: rotate 10s linear infinite;
}
.on {
	background: url('/static/img/on.png') no-repeat center / 100% 100%;
}
.off {
	background-image: url('/static/img/off.png');
}
</style>
